package com.sunny.design.prototype.shallow;

import com.sunny.design.prototype.Prototype;

import java.util.List;

/**
 * 浅克隆
 *
 * @author Sunny
 * @date 2019/12/31 16:31
 */
public class ShallowPrototype implements Prototype {
    private String name;
    private int age;
    private List<String> hobbies;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public List<String> getHobbies() {
        return hobbies;
    }

    public void setHobbies(List<String> hobbies) {
        this.hobbies = hobbies;
    }

    @Override
    public ShallowPrototype clone() {
        ShallowPrototype prototype = new ShallowPrototype();
        prototype.setAge(this.age);
        prototype.setName(this.name);
        prototype.setHobbies(this.hobbies);
        return prototype;
    }
}
